package play;

import org.antlr.v4.runtime.ParserRuleContext;

import java.util.LinkedList;
import java.util.List;

public class NameSpace extends BlockScope {
    private NameSpace parent = null;
    private List<NameSpace> subNameSPaces = new LinkedList<>();

    private String name = null;

    protected NameSpace(String name, Scope enclosingScope, ParserRuleContext ctx) {
        this.name = name;
        this.enclosingScope = enclosingScope;
        this.ctx = ctx;
    }

    @Override
    public String getName() {
        return name;
    }

    public void addSubNameSpace(NameSpace child) {
        child.parent = this;
        subNameSPaces.add(child);
    }

    public void removeSubNameSpace(NameSpace child) {
        child.parent = null;
        subNameSPaces.remove(child);
    }

    @Override
    public String toString() {
        return "NameSpace_" +
                "name='" + name + '\'';
    }
}
